import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Partes extends JPanel implements MouseListener,MouseMotionListener
{
    private String imagem;
    private String tipo;
    private int posX;
    private int posY;
    private int origX;
    private int origY;
    private int sizeX;
    private int sizeY;
    private int iniX;
    private int iniY;
    Mapeamento M;
    
    public Partes(String img, String tp, int x, int y, int sx, int sy, Mapeamento m)
    {
        imagem = img;
        tipo = tp;
        origX = x;
        origY = y;
        iniX = x ;
        iniY = y;
        posX = x;
        posY = y;
        sizeX = sx;
        sizeY = sy;
        M = m;
        this.addMouseListener(this);
        this.addMouseMotionListener(this);
    }
    
 	public void mouseDragged(MouseEvent e)
	{

	}
	
	public void mouseExited(MouseEvent e)
	{

		
	}
	
	public void mouseMoved(MouseEvent e)
	{
		
	}
	
	public void mouseEntered(MouseEvent e)
	{
		
	}
	
	public void mouseClicked(MouseEvent e)
	{
		
	}
	
	public void mouseReleased(MouseEvent e)
	{

	}
	
	public void mousePressed(MouseEvent e)
	{
		int mouseX = e.getX();
		int mouseY = e.getY();
        
		if(((mouseX >= posX) && (mouseX <= (posX + sizeX)) && ((mouseY >= posY) && (mouseY <= (posY + sizeY)))))
		{
          colisao();
			
		}
		else
		{
		
		}
	}
	
	public String getImagem()
	{
		return imagem;
	}
	
	public int getX()
	{
		return posX;
	}
	
	public int getY()
	{
		return posY;
	}
	
	public String getTipo()
	{
		return tipo;
	}
	public void colisao()
	{
		if (tipo == M.getParteControle())
		{
			M.acerto();
			M.trocaMape();
		}
	}

}
